<?php
/**
 * Created by PhpStorm.
 * User: godjarvis
 * Date: 2020/08/05
 * Time: 09:15
 */

namespace App\Model\Dao;

use App\Model\Entity\User;
use Fresh\Facade\Db;
use Fresh\Mvc\Model\Dao;

class UserDao extends Dao
{
    public function update($id, $row)
    {
        return Db::update(User::class, $row, $this->expr()->where('id=?', $id));
    }

    public function getById($id)
    {
        return $this->expr()
            ->from(User::class)
            ->where('id=?', $id)
            ->query()
            ->findFirst();
    }

    public function getByAccountAndMobile($username)
    {
        return $this->expr()
            ->from(User::class)
            ->where('account=?', $username)
            ->orWhere('mobile=?', $username)
            ->query()
            ->findFirst();
    }
}
